﻿using Styx.Common;
using Styx.CommonBot;
using Styx.TreeSharp;
using Action = Styx.TreeSharp.Action;

namespace MIBWarlock
{
    public partial class Classname
    {
        #region DemonologyRotation

        private Composite DemonologyRotation()
        {
            return new PrioritySelector(
                new Action(delegate
                {
                    //target the lowest threat unit
                    if (MIBSettings.Instance.AutoTarget && Me.CurrentTarget != null &&
                        Me.CurrentTarget.IsValid && Me.CurrentTarget.Distance > 30 && GetUnitNear() &&
                        UnitNear.IsValid && Me.CurrentTarget != UnitNear)
                    {
                        UnitNear.Target();
                        Logging.Write(LogLevel.Diagnostic, "Wechsle zum nähesten Gegner");
                    }

                    //target the lowest threat unit
                    if (MIBSettings.Instance.AutoTarget && Me.CurrentTarget == null &&
                        GetUnitNear() &&
                        UnitNear.IsValid)
                    {
                        UnitNear.Target();
                        Logging.Write(LogLevel.Diagnostic, "Target nähesten Gegner");
                    }

                    //Hold dps on Dungeon 
                    if ((Me.CurrentMap.IsDungeon ||
                         Me.CurrentMap.IsRaid) &&
                        !Me.Combat &&
                        Me.CurrentTarget != null &&
                        IsEnemy(Me.CurrentTarget) &&
                        !Me.CurrentTarget.IsTargetingMyPartyMember &&
                        !Me.CurrentTarget.IsTargetingMyRaidMember &&
                        !Me.CurrentTarget.IsTargetingMeOrPet)
                    {
                        return RunStatus.Success;
                    }

                    return RunStatus.Failure;
                }),
                //But first, facing target
                new Decorator(
                    ret =>
                    MIBSettings.Instance.AutoFace &&
                    Attackable(Me.CurrentTarget) &&
                    !Blacklist.Contains(Me.CurrentTarget, BlacklistFlags.All) &&
                    (Me.CurrentTarget.IsTargetingMeOrPet ||
                     Me.CurrentTarget.IsTargetingMyPartyMember ||
                     Me.CurrentTarget.IsTargetingMyRaidMember) &&
                    Me.CurrentTarget.Distance < 15 &&
                    !Me.Mounted &&
                    !IsOverrideModeOn &&
                    !Me.IsFacing(Me.CurrentTarget),
                    new Action(delegate
                    {
                        Me.CurrentTarget.Face();
                        return RunStatus.Failure;
                    })
                    ),
                //Starting the movement right here
                MovementMoveBehind(ret => Me.CurrentTarget),
                MovementMoveToMelee(ret => Me.CurrentTarget),
                MovementMoveStop(ret => Me.CurrentTarget, 3)
                //DPS Rotation Here
                //WriteTargetInfo(),
                //PickHealingSphere(),
                //PickChiSphere(),
                //SpearHandStrike(),
                //SetAutoAttack(),
                //FortifyingBrew(),
                //DampenHarm(),
                //EnergizingBrew(),
                //TigereyeBrew(),
                //ChiBrew(),
                //TigersLustMe(),
                //FlyingSerpentKick(),
                //Roll(),
                //Provoke(),
                //TouchofDeath(),
                //LegSweepInterrupt(),
                //ChargingOxWaveInterrupt(),
                //CracklingJadeLightningPushBackWW(),
                //DiffuseMagic(),
                //LegSweepMeLowHP(),
                //LegSweepEnemyLowHP(),
                //ChargingOxWaveMeLowHP(),
                //ChargingOxWaveEnemyLowHP(),
                //QuakingPalmMeLowHP(),
                //TouchofKarma(),
                //HealingSphereUrgent(),
                //Disable(),
                //InvokeXuen(),
                //TigerPowerBuff(),
                //ExpelHarm(),
                //JabCapEnergy(),
                //RisingSunKick(),
                //ChiWaveMe(),
                //ZenSphereMe(),
                //RushingJadeWind(),
                //SpinningCraneKick(),
                //JabNearCapEnergy(), //48000
                //FistsofFury(),
                //BlackoutKickProc(),
                //TigerPowerProc(),
                //BlackoutKick(),
                //Jab(),
                //HealingSphereCombat(),
                //SpinningFireBlossom(),
                //HealingSphereNoCombat(),
                //HealingSphereCombatBeforeReachingEnemy(),
                //LegacyoftheEmperor(),
                //LegacyoftheWhiteTiger()
                );
        }

        #endregion
    }
}